using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


/// <summary>
/// The TravelDocTypeTableManager class is responsible for managing BO.TravelDocTypeTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class TravelDocTypeTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all TravelDocTypeTable objects in the database.
/// </summary>
/// <returns>A list with all TravelDocTypeTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static TravelDocTypeTableList GetList(){
return TravelDocTypeTableDB.GetList();
}

/// <summary>
/// Gets a single TravelDocTypeTable from the database without its data.
/// </summary>
/// <param name="travelDocTypeCode">The TravelDocTypeCode of the TravelDocTypeTable in the database.</param>
/// <returns>A TravelDocTypeTable object when the TravelDocTypeCode exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static TravelDocTypeTable GetItem(short travelDocTypeCode){
return GetItem(travelDocTypeCode, false);
}

/// <summary>
/// Gets a single TravelDocTypeTable from the database.
/// </summary>
/// <param name="travelDocTypeCode">The TravelDocTypeCode of the TravelDocTypeTable in the database.</param>
/// <param name="getTravelDocTypeTableRecords">Determines whether to load all associated TravelDocTypeTable records as well.</param>
/// <returns>
/// A TravelDocTypeTable object when the TravelDocTypeCode exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static TravelDocTypeTable GetItem(short travelDocTypeCode, bool getTravelDocTypeTableRecords){
TravelDocTypeTable myTravelDocTypeTable = TravelDocTypeTableDB.GetItem(travelDocTypeCode);
return myTravelDocTypeTable;
}

/// <summary>
/// Saves a TravelDocTypeTable in the database.
/// </summary>
/// <param name="myTravelDocTypeTable">The TravelDocTypeTable instance to save.</param>
/// <returns>The new TravelDocTypeCode if the TravelDocTypeTable is new in the database or the existing TravelDocTypeCode when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static short Save(TravelDocTypeTable myTravelDocTypeTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
short travelDocTypeTableTravelDocTypeCode = TravelDocTypeTableDB.Save(myTravelDocTypeTable);

//  Assign the TravelDocTypeTable its new (or existing TravelDocTypeCode).
myTravelDocTypeTable.TravelDocTypeCode = travelDocTypeTableTravelDocTypeCode;

myTransactionScope.Complete();

return travelDocTypeTableTravelDocTypeCode;
}
}

/// <summary>
/// Deletes a TravelDocTypeTable from the database.
/// </summary>
/// <param name="myTravelDocTypeTable">The TravelDocTypeTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(TravelDocTypeTable myTravelDocTypeTable){
return TravelDocTypeTableDB.Delete(myTravelDocTypeTable.TravelDocTypeCode);
}

#endregion

}

